package lt.ntec.danblog.client.blog;

import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.SubmitButton;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

class PostForm extends FormPanel {

    public PostForm() {
        super(new NamedFrame("_self"));
        // Create a FormPanel and point it at a service.
        this.setAction("/blog/new");

        // Because we're going to add a FileUpload widget, we'll need to set the
        // form to use the POST method, and multipart MIME encoding.
        this.setEncoding(FormPanel.ENCODING_URLENCODED);
        this.setMethod(FormPanel.METHOD_POST);

        final TextBox title = new TextBox();
        title.setName("title");
        title.setWidth("100%");


        // final RichTextEditor content = new RichTextEditor();
        final TextArea content = new TextArea();
        content.setName("content");
        content.setWidth("100%");
        content.setHeight("200px");

        final TextBox tags = new TextBox();
        tags.setName("tags");
        tags.setWidth("100%");

        // Create a panel to hold all of the form widgets.
        VerticalPanel panel2 = new VerticalPanel();
        panel2.setWidth("100%");
        panel2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

        VerticalPanel panel = new VerticalPanel();
        panel.setWidth("75%");
        panel2.add(panel);

        this.setWidget(panel2);

        panel.add(new Label("Title"));
        panel.add(title);

        panel.add(new Label("Content"));
        panel.add(content);

        panel.add(new Label("Tags"));
        panel.add(tags);

        panel.add(new SubmitButton("Post"));

        setWidth("100%");
    }
}
